<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #box1 {
            height: 100px;
            width: 100px;
            position: absolute;
            background-color: #bfa;
        }

        #box2 {
            height: 100px;
            width: 100px;
            position: absolute;
            top: 200px;
            background-color: pink;
        }

        .line {
            position: absolute;
            top: 0;
            left: 800px;
            height: 1000px;
            width: 0;
            border-left: 1px solid black;
        }
    </style>
    <script src="tools.js"></script>
    <script>
        window.onload = function () {
            let box1 = document.getElementById("box1");
            let box2 = document.getElementById("box2");
            let btn1 = document.getElementById("btn1");
            let btn2 = document.getElementById("btn2");
            let btn3 = document.getElementById("btn3");
            let btn4 = document.getElementById("btn4");

            btn1.onclick = function () {
                move(box1, "left", 5, 800);
            }
            btn2.onclick = function () {
                move(box1, "left", 5, 0);
            }
            btn3.onclick = function () {
                move(box2, "left", 5, 800);
            }
            btn4.onclick = function () {
                move(box2, "top", 5, 800);
            }
        }
    </script>
</head>

<body>
    <button id="btn1">点击按钮box1向右移动</button>
    <button id="btn2">点击按钮box1向左移动</button>
    <button id="btn3">点击按钮box2向右移动</button>
    <button id="btn4">点击按钮box2向下移动</button>
    <br><br>
    <div id="box1"></div>
    <div id="box2"></div>
    <div class="line"></div>
</body>

</html>